<template>
  <div>
    <el-form
      :inline="true"
      :model="formInline"
      style="text-align: left"
      class="demo-form-inline"
    >
      <el-form-item>
        <el-input
          v-model="formInline.equipmentUsage"
          placeholder="请输入设备用途"
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="load">查询</el-button>
      </el-form-item>
    </el-form>
    <template>
      <el-table
        ref="multipleTable"
        :data="tableData"
        tooltip-effect="dark"
        style="width: 100%"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="55"> </el-table-column>
        <el-table-column prop="id" label="Id" align="center"></el-table-column>
        <el-table-column
          prop="typeName"
          label="设备类型"
           align="center"
        ></el-table-column>
        <el-table-column prop="equipmentUsage" label="用途" align="center">
        </el-table-column>
        <el-table-column prop="description" label="用途说明"  align="center">
        </el-table-column>
        <el-table-column prop="useDate" label="添加时间" align="center">
        </el-table-column>
      </el-table>
    </template>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="formInline.pageIndex"
      :page-sizes="[2, 4, 6, 8]"
      :page-size="formInline.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="count"
    >
    </el-pagination>
  </div>
</template>
<script>
import { getEnergyManage } from "@/api/energys/EnergyManage";
export default {
  data() {
    return {
      formInline: {
        pageIndex: 1,
        pageSize: 2,
        equipmentUsage: "",
      },
      count: 0,
      tableData: [],
      multipleSelection: [],
    };
  },
  created() {
    this.load();
  },
  methods: {
    load() {
      getEnergyManage(this.formInline).then((res) => {
        this.tableData = res.data.data;
        this.count = res.data.totalCount;
      });
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    handleSizeChange(val) {
      this.formInline.pageSize = val;
      this.load();
    },
    handleCurrentChange(val) {
      this.formInline.pageIndex = val;
      this.load();
    },
  },
};
</script>